<?php

namespace app\adminapi\controller\v1\distributor;

use app\adminapi\controller\AuthController;
use app\services\distributor\DistributorApplicationService;
use think\facade\App;
use app\adminapi\export\DistributorAuditExport;

class DistributorAudit extends AuthController
{
    protected $service;

    public function __construct(App $app, DistributorApplicationService $service)
    {
        parent::__construct($app);
        $this->service = $service;
    }

    public function index()
    {
        $where = $this->request->getMore([
            ['nickname', ''], // 经销商名称
            ['add_time', []], // 添加时间
            ['limit', 15]
        ]);
        $list = $this->service->getAuditList($where);
        return app('json')->success($list);
    }

    public function export(){
        $where = $this->request->getMore([
            ['nickname', ''], // 经销商名称
            ['add_time', []], // 添加时间
            ['limit', 15]
        ]);

        return app()->make(DistributorAuditExport::class)->export($where);
    }

    public function audit()
    {
        $ids = $this->request->post('ids') ?? [];
        $handling_comments = $this->request->post('handling_comments') ?? '';
        $this->service->audit($ids, $handling_comments);
        return app('json')->success(100000);
    }
}